package com.example.Windturbine.Calculation.TreeDOMethod1;

import com.example.Windturbine.Calculation.Method.Method1;

import java.math.BigDecimal;

/**
 * @Author 丁永新
 * @Date 2021/12/23
 */
public class LCACalculateProperties1 implements Method1 {

    public LCAResult1 setProperties(LCAResult1 lcaResult1){
        //PED 的计算
        BigDecimal ped1=lcaResult1.煤.multiply(new BigDecimal(COAL_PED));
        BigDecimal ped2=lcaResult1.石油.multiply(new BigDecimal(OIL_PED));
        BigDecimal ped3=lcaResult1.天然气.multiply(new BigDecimal(GAS_PED));

        BigDecimal p=(ped1.add(ped2).add(ped3)).divide(new BigDecimal(PED_NORMAL),20, BigDecimal.ROUND_HALF_DOWN);
        //lcaResult1.setPED(p);

        //GWP的计算
        BigDecimal gwp1=lcaResult1.co.multiply(new BigDecimal(CO_GWP));
        BigDecimal gwp2=lcaResult1.co2.multiply(new BigDecimal(CO2_GWP));
        BigDecimal gwp3=lcaResult1.ch4.multiply(new BigDecimal(CH4_GWP));
        BigDecimal gwp4=lcaResult1.nox.multiply(new BigDecimal(NOX_GWP));
        BigDecimal gwp5=lcaResult1.cfc11.multiply(new BigDecimal(CFC11_GWP));
        BigDecimal gwp6=lcaResult1.cfc12.multiply(new BigDecimal(CFC12_GWP));
        BigDecimal gwp7=lcaResult1.cfc113.multiply(new BigDecimal(CFC113_GWP));

        BigDecimal p2=(gwp1.add(gwp2).add(gwp3).add(gwp4).add(gwp5).add(gwp6).add(gwp7)).divide(new BigDecimal(GWP_NORMAL),20, BigDecimal.ROUND_HALF_DOWN);
        //lcaResult1.setGWP(p2);
        //AP计算
        BigDecimal ap1=lcaResult1.so2.multiply(new BigDecimal(SO2_AP));
        BigDecimal ap2=lcaResult1.nox.multiply(new BigDecimal(NOX_AP));
        BigDecimal ap3=lcaResult1.h2s.multiply(new BigDecimal(H2S_AP));
        BigDecimal ap4=lcaResult1.hcl.multiply(new BigDecimal(HCL_AP));
        BigDecimal p3=(ap1.add(ap2).add(ap3).add(ap4)).divide(new BigDecimal(AP_NORMAL),20, BigDecimal.ROUND_HALF_DOWN);
        //lcaResult1.setAP(p3);


        //EP计算
        BigDecimal ep1=lcaResult1.nox.multiply(new BigDecimal(NOX_EP));
        BigDecimal ep2=lcaResult1.nh3.multiply(new BigDecimal(NH3_EP));
        BigDecimal ep3=lcaResult1.cod.multiply(new BigDecimal(COD_EP));
        BigDecimal p4=(ep1.add(ep2).add(ep3)).divide(new BigDecimal(EP_NORMAL),20, BigDecimal.ROUND_HALF_DOWN);
        //lcaResult1.setEP(p4);

        //POCP计算
        BigDecimal pocp1=lcaResult1.co.multiply(new BigDecimal(CO_POCP));
        BigDecimal pocp2=lcaResult1.ch4.multiply(new BigDecimal(CH4_POCP));
        BigDecimal p5=(pocp1.add(pocp2)).divide(new BigDecimal(POCP_NORMAL),20, BigDecimal.ROUND_HALF_DOWN);
        //lcaResult1.setPOCP(p5);

        //ODP计算
        BigDecimal odp1=lcaResult1.cfc11.multiply(new BigDecimal(CFC11_ODP));
        BigDecimal odp2=lcaResult1.cfc12.multiply(new BigDecimal(CFC12_ODP));
        BigDecimal odp3=lcaResult1.cfc113.multiply(new BigDecimal(CFC113_ODP));
        BigDecimal p6=(odp1.add(odp2).add(odp3)).divide(new BigDecimal(ODP_NORMAL),20, BigDecimal.ROUND_HALF_DOWN);
        //lcaResult1.setODP(p6);

        //Green value 影响浅值计算
        BigDecimal green1=p.multiply(new BigDecimal(PED_WEIGHT));
        BigDecimal green2=p2.multiply(new BigDecimal(GWP_WEIGHT));
        BigDecimal green3=p3.multiply(new BigDecimal(AP_WEIGHT));
        BigDecimal green4=p4.multiply(new BigDecimal(EP_WEIGHT));
        BigDecimal green5=p5.multiply(new BigDecimal(POCP_WEIGHT));
        BigDecimal green6=p6.multiply(new BigDecimal(ODP_WEIGHT));
        BigDecimal p7=green1.add(green2).add(green3).add(green4).add(green5).add(green6);
        //lcaResult1.setGreenvalue(p7);



        LCAResult1 result=new LCAResult1(0,lcaResult1.get煤(),lcaResult1.get石油(),lcaResult1.get天然气(),lcaResult1.getCo(),lcaResult1.getCo2(),
                lcaResult1.getSo2(),lcaResult1.getNox(),lcaResult1.getCh4(),lcaResult1.getH2s(),lcaResult1.getHcl(),lcaResult1.getCod(),lcaResult1.getNh3(),
                lcaResult1.getCfc11(),lcaResult1.getCfc12(),lcaResult1.getCfc113(),lcaResult1.getCalId(),p,p2,p3,p4,p5,p6,p7);

        return result;
    }

/*    public static void main(String[] args) {
        BigDecimal ped1=new BigDecimal(COAL_PED);
        BigDecimal ped2=new BigDecimal(OIL_PED);
        BigDecimal ped3=new BigDecimal(GAS_PED);

        BigDecimal p=(ped1.add(ped2).add(ped3)).divide(new BigDecimal(PED_NORMAL),20, BigDecimal.ROUND_HALF_DOWN);
        System.out.println(p.toString());
    }*/
}
